package st.business.tepth.business.user.partchoose;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import st.business.tepth.R;
import st.business.tepth.R2;
import st.business.tepth.business.bean.DiagnoseBean;
import st.business.tepth.business.bean.OperationBean;
import st.business.tepth.business.bean.PartBean;
import st.shadow.library.core.base.mvp.MvpFragment;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-03-19 18:20
 */

public class PartChooseDelegate extends MvpFragment<PartChoosePresenter> implements PartChooseContract.View {
    public static PartChooseDelegate newInstance(DiagnoseBean diagnoseBean,
                                                 OperationBean operationBean) {
        Bundle bundle = new Bundle();
      //  bundle.putSerializable("diagnoseBean", diagnoseBean);
        bundle.putSerializable("operationBean", operationBean);
        PartChooseDelegate delegate = new PartChooseDelegate();
        delegate.setArguments(bundle);
        return delegate;
    }

    @BindView(R2.id.et_search)
    EditText mEtSearch;
    @BindView(R2.id.tv_tile)
    TextView mTvTitle;
    @BindView(R2.id.recycler_view_common_goods)
    RecyclerView mRecyclerViewCommon;
    @BindView(R2.id.recycler_view_goods_result)
    RecyclerView mRecyclerViewSearch;
    private DiagnoseBean mDiagnoseBean;
    private OperationBean mOperationBean;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            mDiagnoseBean = (DiagnoseBean) bundle.getSerializable("diagnoseBean");
            mOperationBean = (OperationBean) bundle.getSerializable("operationBean");
        }
    }

    @Override
    public PartChoosePresenter getPresenter() {
        return new PartChoosePresenter(this);
    }

    @Override
    public Object setLayout() {
        return R.layout.delegate_part_choose;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
        mTvTitle.setText("选择物料");
        mRecyclerViewCommon.setLayoutManager(new LinearLayoutManager(_mActivity));
        mRecyclerViewSearch.setLayoutManager(new LinearLayoutManager(_mActivity));

    }

    @OnClick({R2.id.tv_back})
    public void onBack() {
        pop();
    }

    private class Adapter extends BaseQuickAdapter<PartBean, BaseViewHolder> {

        Adapter(int layoutResId, @Nullable List<PartBean> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, PartBean item) {

//            helper.setText(R.id.tv_part_name, item.getMaterial_name());
//            helper.setText(R.id.tv_part_type, "零部件:" + item.getCode());
//            helper.setText(R.id.tv_brand, "品牌:" + item.getBrand());
//            helper.setText(R.id.tv_version, "型号:" + item.getVersion());
//            helper.setText(R.id.tv_specification, "规格:" + item.getSpecification());
//            helper.setText(R.id.tv_batch, "批次:" + item.getBatch());
        }
    }
}